<div class="weekwork weekwork-detail">
    <div>
        <ng-content></ng-content>
        <button *ngIf="addable" nz-button nzType="primary" (click)="addModal()" nzGhost>
            <i nz-icon nzType="plus"></i>新增</button>
        <button *ngIf="deleteable" nz-button nzType="primary" (click)="delAll()" nzGhost>
            <i nz-icon nzType="delete"></i>删除</button>
    </div>


    <!-- <nz-tabset>
        <nz-tab nzTitle="计划明细">
            <div style="height: calc(100vh - 230px);overflow-y: scroll;">
                
            </div>
        </nz-tab>
    </nz-tabset> -->
    <nz-table #table_mx nzSize="small" [nzShowPagination]="false" [nzFrontPagination]="false" [nzData]="tableData_mx"
        nzBordered [nzScroll]="lockHeadScroll">
        <thead>
            <tr>
                <th nzWidth="50px" nzAlign="center" nzShowCheckbox (nzCheckedChange)="checkAll($event)"></th>
                <th nzWidth="50px" nzAlign="center">序号</th>
                <th nzWidth="150px" nzAlign="center">计划日期</th>
                <th nzWidth="150px" nzAlign="center">线别</th>
                <th nzWidth="150px" nzAlign="center">站/区段</th>
                <th nzWidth="100px" nzAlign="center">等级</th>
                <th nzAlign="center">项目</th>
                <th nzWidth="150px" nzAlign="center">设备类型</th>
                <th nzWidth="150px" nzAlign="center">纳入天窗</th>
                <th nzWidth="150px" nzAlign="center">天窗类型</th>
                <th nzWidth="150px" nzAlign="center">上道</th>
                <th nzWidth="150px" nzAlign="center">时间</th>
                <th nzWidth="150px" nzAlign="center">作业类型</th>
                <th nzWidth="150px" nzAlign="center">作业设备</th>
                <th nzWidth="150px" nzAlign="center">配合单位</th>
                <th nzWidth="150px" nzAlign="center">作业单位</th>
                <th nzWidth="150px" nzAlign="center">负责人</th>
                <th nzWidth="150px" nzAlign="center">施工内容</th>
                <th nzWidth="150px" nzAlign="center">备注</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let data of table_mx.data;let i = index" (dblclick)="trDbclick(data)" nz-tooltip
                nzTooltipTitle="双击查看详情" nzTooltipPlacement="bottom" style="cursor:pointer">
                <td nzShowCheckbox [(nzChecked)]="data.checked"></td>
                <td nzAlign="center">{{+i+1}}</td>
                <!-- 计划日期 -->
                <td nzAlign="center">{{data.workdate}}</td>
                <!-- 线别 -->
                <td nzAlign="center">{{data.linename}}</td>
                <!-- 站 -->
                <td nzAlign="center">{{data.stationname}}</td>
                <!-- 登记站 -->
                <!-- <td>{{data.place}}</td> -->
                <!-- 行别 -->
                <!-- <td>{{data.xingbie}}</td> -->
                <!-- 等级 -->
                <td nzAlign="center">{{lvlList[data.lvl]||data.lvl}}</td>
                <!-- 项目 -->
                <td>{{data.projectname}}</td>
                <!-- 设备类型 -->
                <td>{{data.devtypename}}</td>
                <!-- 纳入天窗 -->
                <td nzAlign="center">{{tc_sdStatus[data.needskywin]||''}}</td>
                <!-- 天窗类型 -->
                <td>{{data.tctype}}</td>
                <!-- 上道 -->
                <td>{{tc_sdStatus[data.needroad]||''}}</td>
                <!-- 时间 -->
                <td nzAlign="center">{{data.begintime}}-{{data.endtime}}</td>
                <!-- 作业类型 -->
                <td>{{data.projecttype}}</td>
                <!-- 作业来源 -->
                <!-- <td>{{data.source}}</td> -->
                <!-- 作业设备 -->
                <td>{{data.devname}}</td>
                <!-- 配合单位 -->
                <td nzAlign="center">{{data.cooperate}}</td>
                <!-- 作业单位及负责人 -->
                <td nzAlign="center">{{data.orgname}}</td>
                <td nzAlign="center">{{data.charge}}</td>
                <!-- 施工内容 -->
                <td>{{data.content}}</td>
                <!-- 备注 -->
                <td>{{data.note}}</td>
            </tr>
        </tbody>
    </nz-table>
    <div style="display: flex;justify-content: space-between;">
        <div style="padding:5px 10px">
            每页
            <nz-select [(ngModel)]="pageSize" (ngModelChange)="pageSizeChange($event)">
                <nz-option nzValue="10" nzLabel="10"></nz-option>
                <nz-option nzValue="50" nzLabel="50"></nz-option>
                <nz-option nzValue="100" nzLabel="100"></nz-option>
                <nz-option nzValue="200" nzLabel="200"></nz-option>
            </nz-select> 条&nbsp;&nbsp;&nbsp;总共<span class="pageTotal">{{pageTotal}}</span>条
        </div>
        <div style="padding:5px 10px">
            <nz-pagination [nzPageSize]="pageSize" [nzPageIndex]="pageIndex" [nzTotal]="pageTotal"
                (nzPageIndexChange)="pageIndexChange($event)"></nz-pagination>
        </div>

    </div>
</div>

<nz-modal [(nzVisible)]="detailVisible" [nzTitle]="detialTitle" (nzOnCancel)="detailCancel()" [nzOkText]="nzOkText"
    (nzOnOk)="detailOk()" nzWidth="80vw">
    <ng-container *ngTemplateOutlet="detailMode==='detail'?temp_detail:temp_edit"></ng-container>
</nz-modal>

<ng-template #temp_edit>
    <nz-descriptions nzTitle="周计划" nzBordered nzSize="small">
        <nz-descriptions-item nzTitle="项目">
            <!-- <ng-container *ngIf="editData.source==='0'; else temp_project">
                {{editData.projectname}}
            </ng-container>
            <ng-template #temp_project>
            </ng-template> -->
            <nz-tree-select [nzNodes]="zyList" [(ngModel)]="editData.projectid" (ngModelChange)="zyxmChange($event)"
                style="width: 100%;" [nzDropdownStyle]="dropdownStyle" nzDropdownMatchSelectWidth="false">
            </nz-tree-select>

        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="计划日期">
            <div style="display: flex;">
                <button nz-button nzType="default" (click)="addJhrq(temp_jhrq)" nzSize="small">
                    <i nz-icon nzType="plus"></i></button>
                <textarea nz-input [(ngModel)]="editData.plandate" nzAutosize></textarea>
            </div>

            <ng-template #temp_jhrq>
                <nz-list [nzDataSource]="jhrqDates" [nzRenderItem]="item" [nzGrid]="{ gutter: 5, span:3 }"
                    style="width: 60vw;">
                    <ng-template #item let-item>
                        <nz-list-item [nzContent]="nzContent">
                            <ng-template #nzContent>
                                <nz-card [nzTitle]="item.title" nzHoverable (click)="selectJhrq(item.value)">
                                    {{item.value}}
                                </nz-card>
                            </ng-template>
                        </nz-list-item>
                    </ng-template>
                </nz-list>
                <textarea nz-input [ngModel]="selectedJhrq.join()" [nzAutosize]="true" placeholder=""></textarea>
            </ng-template>


        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="等级">
            <!-- <input nz-input [(ngModel)]="editData.lvl"> -->
            {{editData._lvl}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="设备类型">
            <!-- <input nz-input [(ngModel)]="editData.devtypename"> -->
            {{editData.devtypename}}
        </nz-descriptions-item>



        <nz-descriptions-item nzTitle="作业类型">
            <!-- <input nz-input [(ngModel)]="editData.projecttype"> -->
            {{editData.projecttype}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="站/区段">
            <nz-tree-select (ngModelChange)="czChange($event)" [nzDropdownStyle]="dropdownStyle" style="width: 100%"
                [nzNodes]="czList" [(ngModel)]="editData.station">
            </nz-tree-select>
            <!-- <nz-tree-select (ngModelChange)="czChange($event)" [nzDropdownStyle]="dropdownStyle" nzMultiple
                style="width: 100%" [nzNodes]="czList" [(ngModel)]="editData._station">
            </nz-tree-select> -->
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="作业设备">
            <!-- <input nz-input [(ngModel)]="editData.devname"> -->
            <nz-select [(ngModel)]="editData._devids" nzAllowClear style="width: 100%;" nzMode="multiple">
                <nz-option *ngFor="let item of shebeiList" [nzLabel]="item.opName" [nzValue]="item.opValue">
                </nz-option>
            </nz-select>

        </nz-descriptions-item>

        <nz-descriptions-item nzTitle="线别">
            <!-- <input nz-input [(ngModel)]="editData.line"> -->
            <nz-tree-select [nzDropdownStyle]="dropdownStyle" style="width: 100%" [nzNodes]="lineList"
                [(ngModel)]="editData.line">
            </nz-tree-select>
        </nz-descriptions-item>

        <nz-descriptions-item nzTitle="纳入天窗">
            <nz-select [(ngModel)]="editData.needskywin" nzAllowClear style="width: 100%;">
                <nz-option nzLabel="需要" nzValue="0"></nz-option>
                <nz-option nzLabel="不需要" nzValue="1"></nz-option>
            </nz-select>
        </nz-descriptions-item>

        <nz-descriptions-item nzTitle="天窗类型">
            <input nz-input [(ngModel)]="editData.tctype">
        </nz-descriptions-item>

        <nz-descriptions-item nzTitle="上道">
            <nz-select [(ngModel)]="editData.needroad" nzAllowClear style="width: 100%;">
                <nz-option nzLabel="需要" nzValue="0"></nz-option>
                <nz-option nzLabel="不需要" nzValue="1"></nz-option>
            </nz-select>
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="时间">
            <nz-time-picker [(ngModel)]="editData._begintime" nzFormat="HH:mm" nzPlaceHolder="开始时间"></nz-time-picker>
            <nz-time-picker [(ngModel)]="editData._endtime" nzFormat="HH:mm" nzPlaceHolder="结束时间"></nz-time-picker>
        </nz-descriptions-item>


        <nz-descriptions-item nzTitle="配合单位">
            <input nz-input [(ngModel)]="editData.cooperate">
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="作业单位">
            <ng-container *ngIf="orgType==='1'; else tempZydw">
                {{editData.orgname}}
            </ng-container>
            <ng-template #tempZydw>
                <nz-select [(ngModel)]="editData._orgid" nzMode="multiple" nzAllowClear style="width: 100%;">
                    <nz-option *ngFor="let item of zydwList" [nzLabel]="item.opName" [nzValue]="item.opValue">
                    </nz-option>
                </nz-select>

            </ng-template>

            <!-- <input nz-input [(ngModel)]="editData.orgname"> -->
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="负责人">
            <input nz-input [(ngModel)]="editData.charge">
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="备注" [nzSpan]="3">
            <textarea nz-input [(ngModel)]="editData.note" nzAutosize></textarea>
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="施工内容" [nzSpan]="3">
            <textarea nz-input [(ngModel)]="editData.content" nzAutosize></textarea>
        </nz-descriptions-item>
    </nz-descriptions>
</ng-template>


<ng-template #temp_detail>
    <nz-descriptions nzTitle="周计划" nzBordered nzSize="small">
        <nz-descriptions-item nzTitle="项目">
            {{detailData.projectname}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="计划日期">
            {{detailData.workdate}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="等级">
            {{detailData.lvl}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="设备类型">
            {{detailData.devtypename}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="作业类型">
            {{detailData.projecttype}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="站/区段">
            {{detailData.stationname}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="作业设备">
            {{detailData.devname}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="线别">
            {{detailData.linename}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="天窗类型">
            {{detailData.tctype}}
            <!-- <input nz-input [(ngModel)]="editData.tctype"> -->
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="时间">
            {{detailData.begintime}}-{{detailData.endtime}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="配合单位">
            {{detailData.cooperate}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="作业单位">
            {{detailData.orgname}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="负责人">
            {{detailData.charge}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="备注" [nzSpan]="3">
            {{detailData.note}}
        </nz-descriptions-item>
        <nz-descriptions-item nzTitle="施工内容" [nzSpan]="3">
            {{detailData.content}}
        </nz-descriptions-item>
    </nz-descriptions>
</ng-template>